package com.bwie.controller;
import com.bwie.pojo.Order;
import com.bwie.pojo.ProdInfo;
import com.bwie.service.OrderService;
import com.bwie.service.impl.OrderServiceImpl;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
* 订单表(tb_order)表控制层
*
* @author xxxxx
*/
@RestController
@RequestMapping("/shop/order")
public class OrderController {
/**
* 服务对象
*/
    @Autowired
    private OrderService orderService;

    @ApiOperation("order列表")
    @PostMapping("/orderList")
    public R orderList(@RequestBody PageInfoVo pageInfoVo){
        return orderService.orderList(pageInfoVo);
    }

    @ApiOperation("新增订单")
    @PostMapping("/addOrder")
    public R addOrder(@RequestBody List<ProdInfo> infoList){
        return orderService.addOrder(infoList);
    }

    @ApiOperation("导出")
    @GetMapping("/exportOrderList/{userId}")
    public void exportOrderList(@PathVariable("userId") Integer userId){
        orderService.exportOrderList(userId);
    }

    @ApiOperation("根据订单ID获取订单详情")
    @PostMapping("/getOrderInfoById/{orderId}")
    public R getOrderInfoById(@PathVariable Integer orderId){
        return orderService.getOrderInfoById(orderId);
    }
}
